<include file="Public:header" />
<form action="" method="" class="definewidth m20" id="records-form">
<table class="table table-bordered table-hover definewidth m10">
    <tr>
        <input type="hidden" name="equ_repair_records_id" value="{$equ_repair_records['equ_repair_records_id']}"/>
        <td class="tableleft">维保纪录编号</td>
        <td><input type="text" name="repair_record_no" value="{$equ_repair_records['repair_record_no']}"/></td>
    </tr>
    <tr>
        <td class="tableleft">设备编号</td>
        <td>
            <select name="equipment_id">
                <foreach name="equipment" item="e_val">
                    <option value="{$e_val['equipment_id']}" <if condition="$equ_repair_records['equipment_id'] eq $e_val['equipment_id']">selected</if> > {$e_val.number}({$e_val.name})</option>
                </foreach>
            </select>
        </td>
    </tr>
    <tr>
        <td class="tableleft">维保人员</td>
        <td>
            <select name="user_id">
                <foreach name="users" item="u_val">
                    <option value="{$u_val['user_id']}" <if condition="$equ_repair_records['user_id'] eq $u_val['user_id']">selected</if> >{$u_val.user_id}--{$u_val.name}({$u_val.nickname})</option>
                </foreach>
            </select>
        </td>
    </tr>
    <tr>
        <td class="tableleft">合同编号</td>
        <td>
            <select name="contract_id">
                <foreach name="contract" item="c_val">
                    <option value="{$c_val['contract_id']}" <if condition="$equ_repair_records['contract_id'] eq $c_val['contract_id']">selected</if> >{$c_val.contract_id}--{$c_val.company_name}</option>
                </foreach>
            </select>
        </td>
    </tr>
    <tr>
        <td class="tableleft">企业</td>
        <td>
            <select name="company_id">
                <foreach name="company" item="com_val">
                    <option value="{$com_val['company_id']}" <if condition="$equ_repair_records['company_id'] eq $com_val['company_id']">selected</if> >{$com_val.name}({$com_val.company_id})</option>
                </foreach>
            </select>
        </td>
    </tr>
    <tr>
        <td class="tableleft">维修时间</td>
        <td>
            <input type="date" name="repair_time" value="{$equ_repair_records['repair_time']|date='Y-m-d',###}"/>
        </td>
        <input type="hidden" name="comment_id" value="{$equ_repair_records['comment_id']}"/>
    </tr>
    <tr>
        <td class="tableleft"></td>
        <td>
            <button class="btn btn-primary" type="button" id="add-records">保存</button> &nbsp;&nbsp;<button type="button" class="btn btn-success" name="backid" id="backid">返回列表</button>
        </td>
    </tr>
</table>
</form>

<script>
    $(function () {
        $('#backid').click(function(){
            window.location.href="{:U('Home/EquRepairRecords/index')}";
        });

        $("#add-records").click(function () {
            data = $("#records-form").serialize();
            $.post(
                    "{:U('Home/EquRepairRecords/save')}",
                    data,
                    function(xhr){
                        if(200 == xhr.status){
                            alert(xhr.msg);
                            location.href = "{:U('Home/EquRepairRecords/index')}"
                        }else {
                            alert(xhr.msg);
                        }
                    }
            );
        });

    });
</script>

<include file="Public:footer" />